/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JPanelConfiguracion.java
 *
 * Created on 23-nov-2011, 11:29:35
 */
package androidutal;

import java.awt.BorderLayout;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;

/**
 *
 * @author blackmoon
 */
public class JPanelConfiguracion extends javax.swing.JPanel {
    private JVentana ventana;
    private PrintWriter escribir;
    
   
    private DefaultComboBoxModel modelProfesores;
    private DefaultComboBoxModel modelCursos;
    private DefaultComboBoxModel modelSalas;
    
    
    /** Creates new form JPanelConfiguracion */
    public JPanelConfiguracion(JVentana ventana) {
        modelProfesores=new DefaultComboBoxModel ();
        modelCursos=new DefaultComboBoxModel ();
        modelSalas=new DefaultComboBoxModel ();
        
        this.ventana=ventana;
    
        initComponents();
        jTextField1.setText(ventana.getDirectorioGuardado());
        jTextField1.setEditable(false);
        
        
         
         this.jWsUtalBin.setText(this.ventana.getConfiguracionSubeYBaja().getCarpetaWeb());
         this.jIpServer.setText(this.ventana.getConfiguracionSubeYBaja().getIp());
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jLabel4 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        TextoProfesor = new javax.swing.JTextField();
        TextoCurso = new javax.swing.JTextField();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        ListaProfesores = new javax.swing.JComboBox();
        jButton4 = new javax.swing.JButton();
        jLabel5 = new javax.swing.JLabel();
        ListaCursos = new javax.swing.JComboBox();
        jButton5 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        ListaSalas = new javax.swing.JComboBox();
        jButton6 = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        TextoSala = new javax.swing.JTextField();
        jButton7 = new javax.swing.JButton();
        jLabel9 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jButton8 = new javax.swing.JButton();
        jLabel8 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jWsUtalBin = new javax.swing.JTextField();
        jButton9 = new javax.swing.JButton();
        jLabel13 = new javax.swing.JLabel();
        jIpServer = new javax.swing.JTextField();
        jButton10 = new javax.swing.JButton();

        jPanel1.setBackground(java.awt.Color.black);
        jPanel1.setMinimumSize(new java.awt.Dimension(454, 386));

        jButton1.setBackground(java.awt.Color.white);
        jButton1.setText("Atras");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText("Configuraciones");

        jLabel1.setBackground(java.awt.Color.white);
        jLabel1.setForeground(java.awt.Color.white);
        jLabel1.setText("Agregar Profesor:");

        jLabel2.setForeground(java.awt.Color.white);
        jLabel2.setText("Agregar Curso:");

        jButton2.setBackground(java.awt.Color.white);
        jButton2.setText("Agregar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton3.setBackground(java.awt.Color.white);
        jButton3.setText("Agregar");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jLabel3.setForeground(java.awt.Color.white);
        jLabel3.setText("Eliminar Profesor:");

        ListaProfesores.setModel(new javax.swing.DefaultComboBoxModel(ventana.getInfo().getProfe()));
        ListaProfesores.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ListaProfesoresActionPerformed(evt);
            }
        });

        jButton4.setBackground(java.awt.Color.white);
        jButton4.setText("Eliminar");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jLabel5.setForeground(java.awt.Color.white);
        jLabel5.setText("Eliminar Curso:");

        ListaCursos.setModel(new javax.swing.DefaultComboBoxModel(ventana.getInfo().getCurso()));
        ListaCursos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ListaCursosActionPerformed(evt);
            }
        });

        jButton5.setBackground(java.awt.Color.white);
        jButton5.setText("Eliminar");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jLabel6.setForeground(new java.awt.Color(255, 255, 255));
        jLabel6.setText("Almacenamiento WS:");

        ListaSalas.setModel(new javax.swing.DefaultComboBoxModel(ventana.getInfo().getSala()));

        jButton6.setBackground(new java.awt.Color(255, 255, 255));
        jButton6.setText("Eliminar");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jLabel7.setForeground(new java.awt.Color(255, 255, 255));
        jLabel7.setText("Agregar Sala:");

        jButton7.setBackground(new java.awt.Color(255, 255, 255));
        jButton7.setText("Agregar");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jLabel9.setForeground(new java.awt.Color(255, 255, 255));
        jLabel9.setText("Eliminar Sala:");

        jTextField1.setEditable(false);
        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });

        jButton8.setText("Agregar");
        jButton8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton8ActionPerformed(evt);
            }
        });

        jLabel8.setForeground(new java.awt.Color(255, 255, 255));
        jLabel8.setText("se requiere la  carpeta del tipo Apache Tomcat 7.0.14/bin/");

        jLabel10.setForeground(new java.awt.Color(255, 255, 255));

        jLabel11.setBackground(javax.swing.UIManager.getDefaults().getColor("white"));
        jLabel11.setForeground(javax.swing.UIManager.getDefaults().getColor("white"));

        jLabel12.setForeground(java.awt.Color.white);
        jLabel12.setText("WSUtal/Web");

        jWsUtalBin.setEditable(false);

        jButton9.setText("Agregar");
        jButton9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton9ActionPerformed(evt);
            }
        });

        jLabel13.setForeground(new java.awt.Color(240, 240, 240));
        jLabel13.setText("Ip Servidor Web");

        jButton10.setText("Agregar");
        jButton10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton10ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 434, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel2)
                            .addComponent(jLabel1)
                            .addComponent(jLabel7))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(TextoSala, javax.swing.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE)
                            .addComponent(TextoCurso, javax.swing.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE)
                            .addComponent(TextoProfesor, javax.swing.GroupLayout.DEFAULT_SIZE, 234, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE)
                                .addComponent(jButton3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(jButton7))
                        .addGap(27, 27, 27))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(0, 347, Short.MAX_VALUE)
                                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 434, Short.MAX_VALUE)
                                .addComponent(jLabel10)))
                        .addContainerGap())
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addContainerGap(164, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel6)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel9))
                                .addGap(18, 18, 18)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(ListaSalas, 0, 233, Short.MAX_VALUE)
                                    .addComponent(ListaCursos, 0, 233, Short.MAX_VALUE)
                                    .addComponent(ListaProfesores, javax.swing.GroupLayout.Alignment.TRAILING, 0, 233, Short.MAX_VALUE)))
                            .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 101, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel13, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jIpServer, javax.swing.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE)
                                    .addComponent(jWsUtalBin, javax.swing.GroupLayout.DEFAULT_SIZE, 230, Short.MAX_VALUE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jButton4, javax.swing.GroupLayout.DEFAULT_SIZE, 72, Short.MAX_VALUE)
                                .addComponent(jButton5))
                            .addComponent(jButton6)
                            .addComponent(jButton8)
                            .addComponent(jButton9)
                            .addComponent(jButton10))
                        .addGap(27, 27, 27))))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(39, 39, 39)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jLabel1)
                    .addComponent(TextoProfesor, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton3)
                    .addComponent(jLabel2)
                    .addComponent(TextoCurso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(TextoSala, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton7))
                .addGap(37, 37, 37)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jButton4)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel3)
                        .addComponent(ListaProfesores, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton5)
                    .addComponent(jLabel5)
                    .addComponent(ListaCursos, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(ListaSalas, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton6)
                    .addComponent(jLabel9))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel8)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel12)
                        .addGap(15, 15, 15)
                        .addComponent(jLabel10)
                        .addGap(30, 30, 30)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGap(0, 46, Short.MAX_VALUE)
                                .addComponent(jButton1)
                                .addContainerGap())
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addGap(0, 77, Short.MAX_VALUE))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jWsUtalBin, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jIpServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel13)
                            .addComponent(jButton10))
                        .addGap(82, 82, 82))))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
    System.out.println(ventana.saveConfig());
    this.setVisible(false);
     ventana.add(ventana.getMenu(),BorderLayout.CENTER);
     ventana.getMenu().setVisible(true); 
     
}//GEN-LAST:event_jButton1ActionPerformed

private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
    // Agragar Un Profe
    if(! ventana.getInfo().existeprofesor(TextoProfesor.getText())){
            try {
                FileWriter fichero = new FileWriter("src/profesores.txt",true);
                 escribir = new PrintWriter(fichero);
                 escribir.print(TextoProfesor.getText());
                 escribir.println();
                 fichero.close();
                 ventana.getInfo().agregarProfe(TextoProfesor.getText());
                 this.recargarModelProfesores(modelProfesores);
                 ListaProfesores.setModel(modelProfesores);
              
                 
            } catch (IOException ex) {
                Logger.getLogger(JPanelConfiguracion.class.getName()).log(Level.SEVERE, null, ex);
            }
    
    }
        
   
}//GEN-LAST:event_jButton2ActionPerformed

private void ListaCursosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ListaCursosActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_ListaCursosActionPerformed

private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
    //Agregar Un Curso  
    if(! ventana.getInfo().existeCurso(TextoCurso.getText())){
            try {
                FileWriter fichero = new FileWriter("src/cursos.txt",true);
                 escribir = new PrintWriter(fichero);
                 escribir.print(TextoCurso.getText());
                 escribir.println();
                 fichero.close();
                 ventana.getInfo().agregarCurso(TextoCurso.getText());
                 this.recargarModelCursos(modelCursos);
                 ListaCursos.setModel(modelCursos);
                 
            } catch (IOException ex) {
                Logger.getLogger(JPanelConfiguracion.class.getName()).log(Level.SEVERE, null, ex);
            }
    
    }
         
}//GEN-LAST:event_jButton3ActionPerformed

private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
    // boton eliminar profe
    Object[] options = {"Aceptar","Cancelar"};
    int n = JOptionPane.showOptionDialog(this,"¿Esta Seguro que desea Eliminar este profesor?","Eliminar profesor",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE, null,options,options[1]);
    if(n==0){
            ventana.getInfo().eliminarProfe((String)ListaProfesores.getSelectedItem()); 
            try {  
                ListaProfesores.removeAllItems();
                ventana.getInfo().recardarDatosEliminacionProfes();
                this.recargarModelProfesores(modelProfesores);     
                ListaProfesores.setModel(modelProfesores);
   
            } catch (FileNotFoundException ex) {
                Logger.getLogger(JPanelConfiguracion.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(JPanelConfiguracion.class.getName()).log(Level.SEVERE, null, ex);
            }
    }
    
}//GEN-LAST:event_jButton4ActionPerformed

private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
    //eliminar un curso
    Object[] options = {"Aceptar","Cancelar"};
    int n = JOptionPane.showOptionDialog(this,"¿Esta Seguro que desea Eliminar este Curso?","Eliminar Curso",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE, null,options,options[1]);
    if(n==0){
            ventana.getInfo().eliminarCurso((String)ListaCursos.getSelectedItem()); 
            try {  
                ListaCursos.removeAllItems();
                ventana.getInfo().recardarDatosEliminacionCursos();
                this.recargarModelCursos(modelCursos);     
                ListaCursos.setModel(modelCursos);
   
            } catch (FileNotFoundException ex) {
                Logger.getLogger(JPanelConfiguracion.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(JPanelConfiguracion.class.getName()).log(Level.SEVERE, null, ex);
            }
    }
}//GEN-LAST:event_jButton5ActionPerformed

private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
Object[] options = {"Aceptar","Cancelar"};
    int n = JOptionPane.showOptionDialog(this,"¿Esta Seguro que desea Eliminar esta Sala?","Eliminar Sala",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE, null,options,options[1]);
    if(n==0){
            ventana.getInfo().eliminarSala((String)ListaSalas.getSelectedItem()); 
            try {  
                ListaSalas.removeAllItems();
                ventana.getInfo().recardarDatosEliminacionSalas();
                this.recargarModelSalas(modelSalas);     
                ListaSalas.setModel(modelSalas);
   
            } catch (FileNotFoundException ex) {
                Logger.getLogger(JPanelConfiguracion.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(JPanelConfiguracion.class.getName()).log(Level.SEVERE, null, ex);
            }
    }
}//GEN-LAST:event_jButton6ActionPerformed

private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
    if(! ventana.getInfo().existeSala(TextoSala.getText())){
            try {
                FileWriter fichero = new FileWriter("src/salas.txt",true);
                 escribir = new PrintWriter(fichero);
                 escribir.print(TextoSala.getText());
                 escribir.println();
                 fichero.close();
                 ventana.getInfo().agregarSala(TextoSala.getText());
                 this.recargarModelSalas(modelSalas);
                 ListaSalas.setModel(modelSalas);
                 
            } catch (IOException ex) {
                Logger.getLogger(JPanelConfiguracion.class.getName()).log(Level.SEVERE, null, ex);
            }
    
    }
}//GEN-LAST:event_jButton7ActionPerformed

    private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton8ActionPerformed
        // TODO add your handling code here:
        final JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int result= fc.showOpenDialog(this);
        fc.setVisible(true);
        if (result==JFileChooser.APPROVE_OPTION)
     {
            String direccion = fc.getSelectedFile().getAbsolutePath();
            jTextField1.setText(direccion);
            FileWriter fichero;
            try {
                fichero = new FileWriter("src/source.txt");
                escribir = new PrintWriter(fichero);
                escribir.print(jTextField1.getText());
                fichero.close();
                ventana.cargardirectorio();
             FileCopy.FileCopy("src/source.txt",ventana.getDirectorioGuardado()+"/source.txt");
            } catch (IOException ex) {
                Logger.getLogger(JPanelConfiguracion.class.getName()).log(Level.SEVERE, null, ex);
            }
           
  
     }
        
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTextField1ActionPerformed

    private void ListaProfesoresActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ListaProfesoresActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_ListaProfesoresActionPerformed

private void jButton9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton9ActionPerformed
// TODO add your handling code here:
    final JFileChooser fc = new JFileChooser();
        fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int result= fc.showOpenDialog(this);
        fc.setVisible(true);
        if (result==JFileChooser.APPROVE_OPTION)
     {
            String direccion = fc.getSelectedFile().getAbsolutePath();
            jWsUtalBin.setText(direccion); 
            this.ventana.configuracionSubeYBaja.setCarpetaWeb(direccion);
  
     }
}//GEN-LAST:event_jButton9ActionPerformed

private void jButton10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton10ActionPerformed
// TODO add your handling code here:
    this.ventana.configuracionSubeYBaja.setIp(this.jIpServer.getText());
}//GEN-LAST:event_jButton10ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox ListaCursos;
    private javax.swing.JComboBox ListaProfesores;
    private javax.swing.JComboBox ListaSalas;
    private javax.swing.JTextField TextoCurso;
    private javax.swing.JTextField TextoProfesor;
    private javax.swing.JTextField TextoSala;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JTextField jIpServer;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jWsUtalBin;
    // End of variables declaration//GEN-END:variables

    private void recargarModelProfesores(DefaultComboBoxModel modelo) {
        ArrayList<String> profes = ventana.getInfo().profesores;
        for(String profe : profes){
            modelo.addElement(profe);
        }
            
        
    }

    private void recargarModelCursos(DefaultComboBoxModel modelCursos) {
        ArrayList<String> cursos = ventana.getInfo().cursos;
        for(String curso : cursos){
            modelCursos.addElement(curso);
        }
    }
    
    private void recargarModelSalas(DefaultComboBoxModel modelSalas) {
        ArrayList<String> salas = ventana.getInfo().arrSalas;
        for(String sala : salas){
            modelSalas.addElement(sala);
        }
    }

    
}
